#!/bin/bash

if [[ ! -e $1 ]]
then
    echo "Usage: $0 <source path>"
    exit 1
fi

echo "=======scan source code======="
mkdir -p ~/db
find $1 -name '*.[cChHsSxX]' -print > ~/db/cscope.files
find $1 -name '*.m4' -print >> ~/db/cscope.files

echo "========generate cscope database========="
cd ~/db;cscope -q -b -k

echo "==========generate ctags database==========="
ctags -L cscope.files

